//
//  main.m
//  5-18
//
//  Created by HD on 16-5-18.
//  Copyright (c) 2016年 _gdg. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        
        // insert code here...
        NSLog(@"Hello, World!");
        //NSString *st = @"https://www.baidu.com/s";
        NSString *sn = @"http://127.0.0.1:3000/";
        NSDictionary *par = @{
                              @"wd":@"help",
                              };
        NSMutableArray *re = [NSMutableArray new];
        [par enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
            NSString *str = [NSString stringWithFormat:@"%@=%@",key,obj];
            [re addObject:str];
        }];
        NSString *ri = [re componentsJoinedByString:@"&"];
        //NSLog(@"%@?%@",st,ri);
        ri = [NSString stringWithFormat:@"%@?%@",sn,ri];
        
        NSURL *url = [NSURL URLWithString:ri];
        NSURLRequest *req = [NSURLRequest requestWithURL:url];
        NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:nil];
        NSString *mn = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@",mn);
    }
    return 0;
}

